package com.examples.gateway.config;

import com.examples.gateway.helper.config.GatewayHelperProperties;
import com.examples.gateway.helper.filter.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Dai YaLu
 */
@Configuration
@EnableConfigurationProperties({GatewayHelperProperties.class})
public class GateWayConfiguration {

    @Bean
    public PermissionDisableOrSkipFilter permissionDisableOrSkipFilter() {
        return new PermissionDisableOrSkipFilter();
    }

    @Bean
    public ApiReplayFilter apiReplayFilter() {
        return new ApiReplayFilter();
    }

    @Bean
    public GetPermissionFilter getPermissionFilter() {
        return new GetPermissionFilter();
    }

    @Bean
    public PublicRequestFilter publicRequestFilter() {
        return new PublicRequestFilter();
    }


    @Bean
    public GetUserDetailsFilter getUserDetailsFilter() {
        return new GetUserDetailsFilter();
    }

    @Bean
    public AddJwtTokenFilter addJwtTokenFilter() {
        return new AddJwtTokenFilter();
    }

    @Bean
    public AddPermHeaderFilter addPermHeaderFilter() {
        return new AddPermHeaderFilter();
    }

    @Bean
    public ReWriteJsonReqBodyFilter reWriteJsonReqBodyFilter() {
        return new ReWriteJsonReqBodyFilter();
    }

    @Bean
    public DeveloperRouterFilter developerRouterFilter() {
        return new DeveloperRouterFilter();
    }

    /**
     * 用户登录后即可访问接口
     * @return
     */
    @Bean
    public LoginAccessRequestFilter loginAccessRequestFilter() {
        return new LoginAccessRequestFilter();
    }
    @Bean
    public ApiAuthorityFilter apiAuthorityFilter() {
        return new ApiAuthorityFilter();
    }
}
